package com.wans.user.controller.v1;

import com.wans.user.common.util.UserDTOValidationUtils;
import com.wans.common.result.ResponseResult;
import com.wans.model.user.dtos.UserDTO;
import com.wans.user.service.UserRegisterService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@Slf4j
@SuppressWarnings("all")
public class UserRegisterController {

    @Autowired
    private UserRegisterService userRegisterService;

    /**
     * 用户注册请求
     * @return 响应结果
     */
    @PostMapping("/register")
    public ResponseResult<Void> register(@RequestBody UserDTO userRegisterInfo){
        // 基本校验 账号、密码 - 是否符号要求
        UserDTOValidationUtils.validateUserDTO(userRegisterInfo);

        return userRegisterService.insertUser(userRegisterInfo);
    }

}
